<?php

use Faker\Factory as Faker;
use App\Models\UserUpload;
use App\Repositories\UserUploadRepository;

trait MakeUserUploadTrait
{
    /**
     * Create fake instance of UserUpload and save it in database
     *
     * @param array $userUploadFields
     * @return UserUpload
     */
    public function makeUserUpload($userUploadFields = [])
    {
        /** @var UserUploadRepository $userUploadRepo */
        $userUploadRepo = App::make(UserUploadRepository::class);
        $theme = $this->fakeUserUploadData($userUploadFields);
        return $userUploadRepo->create($theme);
    }

    /**
     * Get fake instance of UserUpload
     *
     * @param array $userUploadFields
     * @return UserUpload
     */
    public function fakeUserUpload($userUploadFields = [])
    {
        return new UserUpload($this->fakeUserUploadData($userUploadFields));
    }

    /**
     * Get fake data of UserUpload
     *
     * @param array $postFields
     * @return array
     */
    public function fakeUserUploadData($userUploadFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'user_id' => $fake->randomDigitNotNull,
            'files' => $fake->word,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $userUploadFields);
    }
}
